﻿using CCWin;
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Configuration;
using System.Data;
using System.Drawing;
using System.Dynamic;
using System.Linq;
using System.Text;
using System.Threading;
using System.Threading.Tasks;
using System.Windows.Forms;

namespace Win.CSkin.Test
{
    public partial class frmLogin : CCSkinMain
    {
        Form1 frm1;

        public frmLogin()
        {
            InitializeComponent();

            ccProBar.Value = 0;
            ccProBar.Maximum = 100;

            string name = ConfigurationManager.AppSettings["ScreenModel"];
            //MessageBox.Show(name);

        }

        private void userLogin_UserLoginClick(object sender, EventArgs e)
        {
            UserInfo frmEmp = new UserInfo
            {
                Owner = this
            };
            //UserInfo frmEmp = new UserInfo();
            if (DialogResult.OK == frmEmp.ShowDialog())
            {
                userLogin.User_Login = true;
                this.userLogin.User_ID = frmEmp.SelEmp.Em_ID.ToString();
                this.userLogin.User_Name = frmEmp.SelEmp.Em_Name.ToString();
                this.userLogin.User_Sex = (Enum_UI.UserSex)int.Parse(frmEmp.SelEmp.Em_Sex);
            }
        }

        private void userLogin_UserLogoutClick(object sender, EventArgs e)
        {
            this.userLogin.User_Login = false;
            //PublicRunInfo.User_PickUper = new T_EmployeeInfo();
        }

        private void button1_Click(object sender, EventArgs e)
        {
            Point p = button1.PointToScreen(new Point(0, button1.Height));
            menutest.Show(p);
        }

        private void button2_Click(object sender, EventArgs e)
        {
            frm1 = new Form1();
            frm1.Show();
            //var result = frm1.ShowDialog(this);
            //if (result == DialogResult.None || result == DialogResult.OK)
            //{
            //    MessageBox.Show("sss");

            //    if (frm1 == null)
            //    {

            //    }
            //}
        }

        private void button3_Click(object sender, EventArgs e)
        {
            frmModelCreate frm = new frmModelCreate();
            frm.Show(this);
        }

        private void button4_Click(object sender, EventArgs e)
        {
            ccProBar.Value = 0;
            ccProBar.Minimum = 0;
            ccProBar.Maximum = 100;
            ccProBar.Text = "";
            ccProBar.Update();
            Thread.Sleep(1000);

            for (int i = 1; i <= 100; i++)
            {
                Thread.Sleep(5);

                ccProBar.Value = i;
                ccProBar.Update();
                ccProBar.Text = i.ToString() + "/100" + "%";

                Application.DoEvents();
            }

            FrmProgress frm = new FrmProgress();
            frm.Show();
        }

        private void button5_Click(object sender, EventArgs e)
        {
            WinPager frm = new WinPager();
            frm.Show(this);
        }

        //private void splitButton1_Click(object sender, EventArgs e)
        //{
        //    MessageBox.Show("split");
        //}

        private void menuOKOnly_Click(object sender, EventArgs e)
        {
            MessageBox.Show("确定");
        }

        private void menuOKClose_Click(object sender, EventArgs e)
        {
            MessageBox.Show("确定关闭");
        }

        private void button6_Click(object sender, EventArgs e)
        {
            Form2 frm = new Form2();
            frm.ShowDialog(this);
        }

        private void button7_Click(object sender, EventArgs e)
        {
            int count = 3;
            while (count <= 3)
            {
                button7.Text = $"倒计时({count})秒";
                Application.DoEvents();

                count--;
                if (count < 0) break;

                Thread.Sleep(1000);
            }

            button7.Text = "倒计时完成";

            Utils.ShowProcessing("正在处理中，请稍候...", this, (obj) =>
            {
                //这里写处理耗时的代码，代码处理完成则自动关闭该窗口
                var arg = obj as ExpandoObject;
                var lst = arg.ToList();
                var tt = lst[1].Value;

                Thread.Sleep(4000);
            }, "test");

            MessageBox.Show("执行");
        }

    }
}
